/*
* Copyright (c)  2017, ueboot.com
* All rights reserved.
* 2017-11-05 17:53:32
*/
package com.ueboot.weishop.repository.order;

import com.ueboot.weishop.entity.order.OrderIssueEntity;
import com.ueboot.core.repository.BaseRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 *  Created by ziv  on 2017-11-05 17:53:32.
 * @author ziv
 * @since 2.0 by autocode
 */
@Repository
public interface OrderIssueRepository extends BaseRepository<OrderIssueEntity, Long> {

	List<OrderIssueEntity> findBySendDmsStatus(String sendDmsStatus);

	OrderIssueEntity findTopBySeqNoOrderByFirstInsertDesc(String seqNo);

	List<OrderIssueEntity> findBySendDmsStatusAndCancelAndSendSmsStatus(String sendDmsStatus, String cancer, String sendSmsStatus);

	List<OrderIssueEntity> findByOrderNo(String orderNo);

	/*@Query(value="select c from WS_ORDER_ISSUE c where c.LAST_SEND_DMS_TIME between :startTime and :endTime order by id desc",
			countQuery = "select count(*) from WS_ORDER_ISSUE c where c.LAST_SEND_DMS_TIME between :startTime and :endTime order by id desc",
			nativeQuery = true)
	public Page<OrderIssueEntity> findAllOrderIssueEntityByTime(Example<OrderIssueEntity> example, Pageable pageable,@Param("startTime") Date startTime,@Param("endTime") Date endTime);
	*/

	@Query(value="select * from WS_ORDER_ISSUE c where c.LAST_SEND_DMS_TIME >= to_date(:startTime,'yyyy-mm-dd hh24:mi:ss') and c.LAST_SEND_DMS_TIME <= to_date(:endTime,'yyyy-mm-dd hh24:mi:ss') order by id desc",
			nativeQuery = true)
	List<OrderIssueEntity> findAllOrderIssueEntityByTime(@Param("startTime") String startTime, @Param("endTime") String endTime);

}
